/*
 * @(#)IndexAreaRIP.java     Didier Gutacker
 *
 */

/** 
 *
 * @author 	Didier Gutacker
 * @version     1.0, 05.09.1997
 * @see SimulationFrame
 * @see Simulation
 * @see Legende
 *
 */

import java.awt.*;

public class IndexAreaRIP extends Legende {

  public IndexAreaRIP( Simulation simulation, SimulationFrame frame ){
    super( simulation , frame );
   repaint();
  }

  public void paint( Graphics gc ) {
    this.gc = gc;
    fontMetrics = gc.getFontMetrics();
    int textHeight = fontMetrics.getAscent() + fontMetrics.getDescent() + 1;
    int y = textHeight, x = 10;

    String str = new String(": " + simulation.getText().routingUpdatePacketText);
 
    Packet routingTableUpdatePacket = new Packet( true, Color.blue, "RoutingTableUpdate", null,0, 1 );
    routingTableUpdatePacket.increaseTravelPercentage( 1, 1 );
    routingTableUpdatePacket.paint( gc, x, y, x + 20, y );
    gc.drawString(str, x + 20, y + textHeight / 2 );
    
    y += textHeight + 5;
    
    Packet routingTableRequestPacket = new Packet( true, Color.orange, "RoutingTableRequest", null, 0, 1 );
    routingTableRequestPacket.increaseTravelPercentage( 1, 1 );
    routingTableRequestPacket.paint( gc, x, y, x + 20, y );
    gc.drawString( ": " + simulation.getText().routingTableRequestPacketText, x + 20, y + textHeight / 2 );
    y += textHeight + 10;
 
    String s = simulation.getText().menuBar_editButton_simulationSpeedButtonText + ": ";
    
    int speed = frame.getAnimationSpeed();
    
    if ( speed == 0 ) {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_slowButtonText;
    } else if ( speed == 1 ) {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_normalButtonText;
    } else {
      s += simulation.getText().menuBar_editButton_simulationSpeedButton_fastButtonText;
    } // if
    gc.drawString( s, x, y );


    if ( frame.demoRunning() ) {
      int x_old = x;
      x += 20 + fontMetrics.stringWidth( s );
      Color oldColor = gc.getColor();
      gc.setColor( Color.red );
      s = simulation.getText().simulationText + " " + simulation.getText().runningText;
      gc.drawString( s, x, y );
      gc.setColor( oldColor );
      x = x_old; 
    } else {
      gc.clearRect( x, y, x + 400, y + textHeight );
    } // if
   
    y = textHeight;
    x += 45 + fontMetrics.stringWidth( str );
    Packet multicastPacket = new Packet( true, Color.magenta, "DataPacket", null, 0,1 );
    multicastPacket.increaseTravelPercentage( 1, 1 );
    multicastPacket.paint( gc, x, y, x + 25, y );
    gc.drawString( ": " + simulation.getText().multicastPacketText, x + 20, y + textHeight / 2 );

  } // IndexAreaRIP.paint

} // IndexAreaRIP


